/**
 * 
 */
package fr.toto.menuitem;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import fr.toto.subtitles.Soutitre;


/**
 * @author tshepo
 *
 */
public class SoutitreMenuItem extends JMenuItem {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2401632319331737173L;

	/**
	 * @param icon
	 */
	public SoutitreMenuItem(final Soutitre s) {
			this.setText(s.toString());
			
			this.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					if (e.getButton() != MouseEvent.BUTTON1) {
						JPopupMenu pm = new JPopupMenu();
						pm.add(new BetaSeriesLinkMenuItem(s.getUrl()));
						pm.add(new SuppMenuItem(s));
						pm.setLocation(e.getLocationOnScreen());
						pm.setInvoker(pm);
						pm.setVisible(true);
					} else {
						new BetaSeriesLinkMenuItem(s.getUrl()).doClick();	
					}
				}
			});
	}

}
